package com.miguo.adapter;

import android.content.Context;
import android.text.TextUtils;

import com.miguo.bean.AdvertBean;
import com.miguo.framework.adapter.BaseAdapterHelper;
import com.miguo.framework.adapter.QuickAdapter;
import com.miguo.ui.R;
import com.miguo.utils.Options;
import com.miguo.utils.StringUtils;

/**
 * File Names: CategoryGridViewAdapter
 * Describe:
 * User: LinXiaoZhi(87100854@qq.com)
 * Date: 2015-07-17
 * Time: 10:58
 */
public class CategoryGridViewAdapter extends QuickAdapter<AdvertBean> {

    public CategoryGridViewAdapter(Context context) {
        super(context, R.layout.layer_home_head_category_adapter);
    }

    @Override
    protected void convert(BaseAdapterHelper helper, AdvertBean item) {
        helper.setText(R.id.category_name_tv, item.getTitle());
        if (StringUtils.isNull(item.getItem_pic_url()) == false && "-1".equals(item.getItem_pic_url()) == false) {
            helper.setImageOptions(R.id.category_icon_iv, item.getItem_pic_url(), Options.getRoundedOptions());
            return;
        }
        if ("-1".equals(item.getItem_pic_url()) || TextUtils.isEmpty(item.getItem_pic_url())) {
            helper.setImageResource(R.id.category_icon_iv, R.drawable.ic_m_all);
            return;
        }
        helper.setImageResource(R.id.category_icon_iv, R.drawable.ic_m_default);
    }

}
